<!--
 * @Author: jiu yin
 * @Date: 2024-04-18 12:06:55
 * @LastEditTime: 2024-04-22 16:16:30
 * @LastEditors: jiu yin zhen jing
 * @FilePath: \web-smart-tour\src\pagesA\tour_log\index.vue
 * jiu
-->
<template>
    <view class="tour-log">
        <custom_navbar :title="navbar_title" theme="light" />
        <view v-if="bigLogList.length > 0" class="log-list">
            <log_item v-for="(item, index) in bigLogList" :key="index" :info="item"></log_item>
        </view>
        <view v-else class="list-nodata">暂无数据</view>
    </view>
</template>

<script>
import { navigateTo, navigateBack } from "@/hooks";
import { scenicWalkList, walkList } from "@/api/home.js";
import custom_navbar from "@/components/custom_navbar/index.vue";
import log_item from "@/components/log_item/index.vue";
import store from "@/store";

export default {
	components: { custom_navbar, log_item },
	data() {
		return {
			navigateTo,
            navbar_title: "游览日志",
            bigLogList: [],
            curPage: 0,
            total: 0,
		}
	},
    mounted() {
	},
    onLoad() {
        this.getLogList();
	},
    onUnload() {
      store.commit("userInfo/set_is_login_popup", false);
    },
    onReachBottom() {
		// this.loadMore();
	},
    methods: {
        loadMore() {
            let isLoad = Math.ceil(this.total / 10) > this.curPage;
            if (isLoad) {
                this.getLogList();
            }
        },
        getLogList() {
            let params = {
                page: this.curPage + 1,
                limit: 10,
                walk_limit: 4
            };
            scenicWalkList(params).then(res => {
                if (res.code == 200) {
                    this.curPage = params.page;
                    let dataArr = [...this.bigLogList];
                    if (params.page > 1) {
						dataArr.push(...res.data.data)
					} else {
						dataArr = res.data.data;
					}
                    this.bigLogList = dataArr;
                }
            })
        }
    },
}
</script>

<style lang="scss" scoped>
.tour-log {
    padding: 24rpx 24rpx 40rpx;
    height: calc(100vh - 64rpx);
    overflow-y: scroll;
    background-color: #F6F9F8;
}
.list-nodata {
    margin-top: 16rpx;
    height: 200rpx;
    line-height: 200rpx;
    text-align: center;
    background-color: #fff;
    border-radius: 32rpx;
}
</style>